<!DOCTYPE HTML>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>AUI快速完成布局</title>
    <link rel="stylesheet" type="text/css" href="../css/aui.css" />
    <style>
        h2 {
            padding-left: 20px;
            height: 50px;
            line-height: 50px;
        }
    </style>

</head>

<body>
    <h2 style="color:#666">
  1、绑定淘宝账号
</h2>
    <div style="padding:0 10px;hight:50px;line-height:50px;">

    </div>
    <div style="padding:0 20px">
        <ul class="aui-list aui-form-list" style="border:1px solid #ff4285">
            <li class="aui-list-item">
                <div class="aui-list-item-inner" style="padding:0 10px">
                    <div class="aui-list-item-label-icon">
                        账号：
                    </div>
                    <div class="aui-list-item-input">
                        <input type="text" placeholder="请输入淘宝账号" id="account">
                    </div>
                </div>
            </li>

        </ul>
    </div>
    <h2 style="color:#666">
      2、淘宝账号信誉等级
    </h2>
    <div style="padding:0 20px">
        <ul class="aui-list aui-form-list" onclick="fnSelectCreditRating();" style="border:1px solid #ff4285">
            <li class="aui-list-item">
                <div class="aui-list-item-inner" style="padding:0 10px">
                    <div class="aui-list-item-label-icon">
                        信誉：
                    </div>
                    <div class="aui-list-item-input" id="id1">

                         <span style="color: #aab2bd;">选择信誉等级</span>
                    </div>
                </div>
            </li>
        </ul>
    </div>
    <div style="padding:10px 26px;">
        <h3 style="color:red">备注：</h3>
        <p style="padding:5px 20px;">1、绑定淘宝淘宝账号可以提高通过率。</p>
        <p style="padding:5px 20px;">2、每个会员可以绑定<span style="color:red">5</span>个淘宝账号。</p>
    </div>
    <p style="text-align:right;color:red;margin-top:20px;padding:10px 20px;" ><span onclick="fnListTaobaoBind()">查看已绑定的淘宝号？</span></p>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="./conf/config.js"></script>
<script type="text/javascript" src="./js/common.js"></script>
<script type="text/javascript" src="../script/jquery-1.8.2.min.js"></script>
<script type="text/javascript">
    apiready = function() {
initRefreshCommon();
      //initEventListenner();
    };

      $("#account").focus(function(){
        $("#footer").hide();
      });
      $("#account").blur(function(){
        $("#footer").show();
      });

    function initEventListenner() {
        api.addEventListener({
            name: 'keyback'
        }, function(ret, err) {
            api.confirm({
                title: '提示',
                msg: '是否退出应用',
                buttons: ['确定', '取消']
            }, function(ret, err) {
                if (ret.buttonIndex == 1) {
                    api.closeWidget({
                        silent: true
                    });
                }
            });
        });
        api.addEventListener({
            name: 'selectCteditRat'
        }, function(ret, err) {
            if (ret) {
                //alert(JSON.stringify(ret));

              $("#id1").html('<img src="'+ret.value.selectCteditRatImg.imgUrl+'" data-lv="'+ret.value.selectCteditRatImg.imgId+'">');


            } else {
                alert(JSON.stringify(err));
            }
        })
    };
    //查看已经绑定的淘宝账号
    function fnListTaobaoBind() {
        api.openWin({
            name: 'list_taobao_bind',
            url: './list_taobao_bind.html',
            opaque: true,
            vScrollBarEnabled: false,
            pageParam: {
                name: 'test'
            }
        });
    }
    //选择淘宝信誉度
    function fnSelectCreditRating() {

          api.openFrame({
            name: 'taobao_select_credit_rating_frame',
            url: './taobao_select_credit_rating_frame.html',
            bgColor: 'rgba(0, 0, 0, 0.5)',
            rect: {
                x: 0,
                y: 0,
                w: 'auto',
                h: 'auto'
            },
            pageParam: {
                name: 'test'
            },

            bounces: false
        });

    }
    function fnSubmitBindTaobaoVal(){
        //发送ajax 请求，返回对返回值进行处理
            var account=$("#account").val();
            var imgObj=$("#id1").find("img");
            if(!imgObj||!account){
              alert("请按要求填写信息");
            }else{
              var bLevel=$(imgObj).attr("data-lv");
              var userInfo = $api.getStorage("userInfo");
            //alert(JSON.stringify(userInfo));
              var userid = userInfo.userid;
              var random = userInfo.random;
              //var type = 0;//淘宝是0，京东是1
              api.ajax({
                  url: SITE_URL+'index.php?m=api&c=appnew&a=bind_tb_info',
                  method: 'post',
                  data: {
                      values: {
                        "account": account,
                        "userid": userid,
                        "random": random,
                        "bLevel": bLevel,
                        "type": 0,
                        "taobao_img": "img/updata_img.png",
                        "friend": "",

                      }
                  }
              }, function(ret, err) {
                switch (ret.status) {
                  case 0:
                      alert(ret.msg);
                      break;
                    case 1:
                    alert(ret.msg);
                    api.openWin({
                        name: "list_taobao_bind",
                        url: "list_taobao_bind.html",
                        opaque: true,
                        vScrollBarEnabled: false
                    });
                        break;
                    case 2:
                        alert(ret.msg);
                        api.openWin({
                            name: 'login',
                            url: './login.html',
                            pageParam: {
                                name: 'test'
                            }
                        });

                        //然后关闭当前网页，跳转到另一个网页；
                        break;

                }


              });

            }

    }

</script>

</html>
